package com.yang.controller;

import com.yang.mapper.SysUserMapper;
import com.yang.pojo.SysUser;
import com.yang.service.LoginService;
import com.yang.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.transform.Result;
import java.util.Date;
import java.util.Map;

/**
 * @Author 杨天可
 * @Date 2021/6/11 14:28
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/login")
public class LoginController {
    @Resource
    LoginService loginService;

    /***
     * 测试
     * @return
     */
    @GetMapping("/test")
    public Map<String,Object> test(){
        return loginService.test();
    }

    /***
     * 用户登录
     * @return 登录是否成功
     */
    @PostMapping("/userLogin")
    public Map<String,Object> userLogin(@RequestBody Map<String,Object> map) {
        String username = (String)map.get("username");
        String password = (String)map.get("password");
        return loginService.userLogin(username, password);
    }

    /***
     * 用户退出登录
     * @return 操作结果
     */
    @GetMapping("/logOut")
    public Map<String, Object> logOut() {
        return loginService.loginOut();
    }
}
